package edu.zqu.instructionalMatters.project.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @Author 何文东
 * @Date 2020/7/3 9:59
 * @Description: 创建时间、更新时间工具类
 * @Version 2.0
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", new Timestamp(new Date().getTime()), metaObject);
        this.setFieldValByName("updateTime", new Timestamp(new Date().getTime()), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", new Timestamp(new Date().getTime()), metaObject);
    }
}
